[XM] Allow empty resource strings (e.g., when creating an empty CDROM
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 23 Oct 2006 11:23:57 +0000 (12:23 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 23 Oct 2006 11:23:57 +0000 (12:23 +0100)
device). Also clean up error/acces-denied path.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/python/xen/util/security.py
tools/python/xen/xm/create.py

index e617ddf89409260be6b46908f96d6431af27d3cc..91c0badd74350c6e31e33f18301c12b70733f16e 100644 (file)
@@ -601,8 +601,15 @@ def unify_resname(resource):
     """Makes all resource locations absolute. In case of physical
     resources, '/dev/' is added to local file names"""
 
+    if not resource:
+        return resource
+
     # sanity check on resource name
-    (type, resfile) = resource.split(":")
+    try:
+        (type, resfile) = resource.split(":")
+    except:
+        err("Resource spec '%s' contains no ':' delimiter" % resource)
+
     if type == "phy":
         if not resfile.startswith("/"):
             resfile = "/dev/" + resfile
index 4b5cd3db7ca22bddb2ffce0ba9a9be89b66c07bb..48486d8bfc27c055996bea51c289d0a2a4fec1cb 100644 (file)
@@ -1143,6 +1143,8 @@ def config_security_check(config, verbose):
         except security.ACMError:
             print "   %s: DENIED" % (resource)
             (res_label, res_policy) = security.get_res_label(resource)
+            if not res_label:
+                res_label = ""
             print "   --> res:"+res_label+" ("+res_policy+")"
             print "   --> dom:"+domain_label+" ("+domain_policy+")"
             answer = 0
@@ -1181,7 +1183,7 @@ def main(argv):
         PrettyPrint.prettyprint(config)
     else:
         if not create_security_check(config):
-            raise OptionError('Security Configuration prevents domain from starting')
+            raise security.ACMError('Security Configuration prevents domain from starting')
         else:
             dom = make_domain(opts, config)
             if opts.vals.console_autoconnect: